package com.wukang.photovoltaicinspectionpictures.ui

import android.content.Intent
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.wukang.photovoltaicinspectionpictures.BuildConfig
import com.wukang.photovoltaicinspectionpictures.base.BaseActivity
import com.wukang.photovoltaicinspectionpictures.base.EmptyViewModel
import com.wukang.photovoltaicinspectionpictures.databinding.ActivityLauncherBinding
import com.wukang.photovoltaicinspectionpictures.ui.main.MainActivity
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds

/**
 * 启动页
 * @author wukang
 */
class LauncherActivity : BaseActivity<ActivityLauncherBinding, EmptyViewModel>() {

    override fun initViewBinding(): ActivityLauncherBinding = ActivityLauncherBinding.inflate(layoutInflater)

    override fun initViewModel(): EmptyViewModel = ViewModelProvider(this)[EmptyViewModel::class.java]

    override fun initActivity() {
        lifecycleScope.launch {
            delay(2.seconds)
            startActivity(Intent(this@LauncherActivity, MainActivity::class.java))
            finish()
        }
    }

    override fun ActivityLauncherBinding.initView() {
        tvAppVersion.text = BuildConfig.APP_BUILD_INFO
    }
}